
import { Vector3 } from '../../math/vector';
import { Component } from "../component";




export class Transform extends Component {

    static {
        globalThis.__Transform__ = new Transform();
    }

    get position(): Vector3 {

        return Deno.core.ops.opGetPosition(this).toVec();
    }

    setPosition(position: Vector3) {
        return Deno.core.ops.opSetPosition(this, position.into());
    }

    get rotation(): Vector3 {
        return Deno.core.ops.opGetRotation(this).toVec();
    }

    setRotation(rotation: Vector3) {
        return Deno.core.ops.opSetRotation(this, rotation.into());
    }

    get scale(): Vector3 {
        return Deno.core.ops.opGetScale(this).toVec();
    }

    setScale(scale: Vector3) {
        return Deno.core.ops.opSetScale(this, scale.into());
    }

    translate(vector: Vector3) {
        return Deno.core.ops.opTranslate(this, vector.into());
    }

    toString() {
        return `Transform { position:${JSON.stringify(this.position)}, rotation:${JSON.stringify(this.rotation)}, scale:${JSON.stringify(this.scale)}}`;
    }
}


